import 'quill/dist/quill.snow.css'
import './editor.css'

import Quill from 'quill'
import audio from './audio.js'

export default {
  props: {
    content: {
      type: [Array, Object, String]
    }
  },
  data: function () {
    return {
      editor: {}
    }
  },
  mounted: function () {
    this.create()
  },
  watch: {
    content: function () {
      this.editor.setContents(this.content)
    }
  },
  methods: {
    create () {
      let options = {
        modules: {
          toolbar: false
        },
        formats: {
          video: true
        },
        theme: 'snow',
        readOnly: true
      }
      Quill.register(audio, true)
      this.editor = new Quill(this.$refs.plEditor, options)
      this.editor.setContents(this.content)
    }
  },
  template: '<div class="kk-editor" ><div ref="plEditor" ></div></div>'
}
